package com.taxi.controller;

import com.taxi.response.NumberCodeResponse;
import com.taxi.result.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Author: aniu
 * @Date: 2023/9/19
 * @ClassName: NumberCodeController
 * @Description: Write class functionality and purpose here.
 * @Version: 1.0
 */
@RestController
public class NumberCodeController {

    @GetMapping("/numberCode/{size}")
    public Result numberCode(@PathVariable("size")int size){
        //获取随机数
        int code = (int)((Math.random() * 9+1)*(Math.pow(10,size-1)));

        //定义返回值
        NumberCodeResponse response = new NumberCodeResponse();
        response.setNumberCode(code);
        return Result.ok(response);
    }
}
